package j07menthod;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class J2shoudong {
    static int count = 100;
    static Lock lock = new ReentrantLock();

    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            while (count>0){
                lock.lock();
                System.out.println("t1卖出="+count);
                count--;
                lock.unlock();
            }
        });
        Thread t2 = new Thread(()->{
            while (count>0){
                lock.lock();
                System.out.println("t222卖出="+count);
                count--;
                lock.unlock();
            }
        });
        t1.start();
        t2.start();
    }
}
